#ifndef __INSERTIONSORT__
#define __INSERTIONSORT__

#include <iostream>
#include <vector>
#include <algorithm>
#include <time.h>
#include "util.h"


// from 0 to end
const int THRESHOLD  = 32;
const int THRESHOLD1 = 16;
const int THRESHOLD2 = 8;
inline void swap(int& a,int& b){
	int tmp=a;
	a=b;
	b=tmp;
}

void insertionsort(int a[],int start=0,int end=THRESHOLD){
	for (int i=start+1;i<end;i++){
		for(int j=i-1;j>=start+0;j--){
			if (a[j+1]<a[j]){
				swap(a[j],a[j+1]);
			}else{break;}
		}
	}
}

#endif